<?php
class block_openid_login extends block_base {
    function init() {
        $this->title = get_string('openid_login_title','block_openid_login');
        $this->version = 2006091300;
    }
    
    function get_content() {
    
    	global $USER, $CFG;
    	
    	$style = "input.openid_login {
				background: url({$CFG->wwwroot}/blocks/openid_login/login-bg.gif) no-repeat;
				background-color: #fff;
				background-position: 0 50%;
				color: #000;
				padding-left: 18px;
				}";
    	
	    if ($this->content !== NULL) {
	        return $this->content;
	    }
	    
	    $this->content->footer = '';
        $this->content->text = '';
        $username = get_moodle_cookie() === 'nobody' ? '' : get_moodle_cookie();
	    
	    if (empty($USER->loggedin) or isguest()) {   // Show the block
	    	$this->content->text .= "<style>$style</style>\n";
            $this->content->text .= '<form class="loginform" name="login" method="post" action="'.$CFG->wwwroot.'/mod/openid_client/login.php">';
            $this->content->text .= '<table align="center" cellpadding="2" cellspacing="0" class="logintable">';
            // $this->content->text .= '<tr><td class="c0 r0" align="right">'.get_string('username').':</td>';
            $this->content->text .= '<tr><td class="c0 r0" colspan="2"><input class="openid_login" type="text" name="username" size="18" value="'.$username.'" /></td></tr>';

            $this->content->text .= '<tr><td colspan="2" class="c1 r2" align="right"><input type="submit" value="'
            	.get_string('login').'" /></td></tr>';

            $this->content->text .= '</table></form>';
		}
	
	    return $this->content;
	}
}
?>